#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int bok[100];
int path[100];
int n;

void dfs(int step)
{
	if(step>n)
	{
		for(int i=1;i<=n;i++) cout<<path[i];
		cout<<endl;
		return ;
	}
	for(int i=1;i<=n;i++)
	{
		if(!bok[i])
		{
			path[step] = i;
			bok[i] = 1;
			dfs(step+1);
			bok[i] = 0;
		}
	}
}


int main()
{
    cin>>n;
	dfs(1);
   //system("pause");
    return 0;
}